#if !defined(_SVALUE_H)
#define _SVALUE_H

#include <sstream>
#include <boost/algorithm/string.hpp>

#include "alias.h"
#include "boost/enable_shared_from_this.hpp"
#include "Utility.h"
#include "SNotImplementedException.h"
#include "SParseException.h"

CREATE_ALIAS( SValue )
CREATE_MAP_ALIAS( SValue )

/**
 *   The abstract base class of all toolkit variable types.
 */
class DECLARATION_DLL SValue : public enable_shared_from_this<SValue>
{
	public:

		/**
		 * Get the variable type.
		 */ 
		virtual SType GetType() const = 0;

		/**
		 * Get the name of the type.
		 */
		virtual string GetTypeName();

		/**
		 * Returns true if the variable is of simple type
		 */ 
		virtual bool IsSimpleType() const = 0;

		/**
		 * Returns true if the variable is of complex type
		 */ 
		virtual bool IsComplexType() const = 0;

		/**
		 * Returns a string representation of the value.
		 */
		virtual string ToString()
		{
			return ToString("");
		}

		/**
		 * Returns a string representation of the value in a specific format.
		 */
		virtual string ToString(string format)
		{
			throw SNotImplementedException("ToString() is not implemented.");
		}

		/**
		 * Very useful template function to convert a SValueSp to a S<T>Sp where T is a SubClass of SValue.
		 * Use GetType() before using this function to be sure about the target variable type.
		 */ 
		template <typename T>
		shared_ptr<T> As()
		{
			return dynamic_pointer_cast<T, SValue>( shared_from_this() );
		}
};

#endif  //_SVALUE_H
